package com.fesine.lock.thread;

import com.fesine.lock.model.MyLock;

/**
 * @description: 类描述
 * @author: Fesine
 * @createTime:2017/4/12 10:44
 * @update:修改内容
 * @author: Fesine
 * @updateTime:2017/4/12 10:44
 */
public class DieThread extends Thread {
    private boolean flag;

    public DieThread(boolean flag) {
        this.flag = flag;
    }

    @Override
    public void run() {
        if (flag) {
            synchronized (MyLock.objA) {
                System.out.println("if objA");
                synchronized (MyLock.objB) {
                    System.out.println("if objB");
                }
            }
        } else {
            synchronized (MyLock.objB) {
                System.out.println("else objB");
                synchronized (MyLock.objA) {
                    System.out.println("else objA");
                }
            }
        }
    }
}
